package com.sztx.worker_monitor.core.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sztx.worker_monitor.core.service.LogService;
import com.sztx.worker_monitor.dataaccess.dao.mysql.LogMysqlDAO;
import com.sztx.worker_monitor.dataaccess.domain.LogDO;
import com.sztx.se.common.util.validate.ValidateUtil;
import com.sztx.se.core.service.impl.BaseServiceImpl;

@Service("logService")
public class LogServiceImpl extends BaseServiceImpl implements LogService {

	@Autowired
	private LogMysqlDAO logMysqlDAO;

	@Override
	public List<LogDO> findUnHandleLogs(Integer taskItemNum, String taskItems, Integer fetchNum) {
		ValidateUtil.notNull(taskItemNum, "taskItemNum不允许为空");
		ValidateUtil.isNotBlank(taskItems, "taskItems不允许为空");
		ValidateUtil.notNull(fetchNum, "fetchNum不允许为空");
		return logMysqlDAO.findUnHandleLogs(taskItemNum, taskItems, fetchNum);
	}

	@Override
	public boolean updateLog(Integer id, Integer oldStatus, Integer newStatus, Integer num) {
		ValidateUtil.notNull(id, "id不允许为空");
		ValidateUtil.notNull(oldStatus, "oldStatus不允许为空");
		ValidateUtil.notNull(newStatus, "newStatus不允许为空");
		ValidateUtil.notNull(num, "num不允许为空");
		int result = logMysqlDAO.updateLog(id, oldStatus, newStatus, num);
		return result > 0;
	}

}
